

//--------------- LOCALIZEABLE GLOBALS ---------------
var d=new Date();
var dayName=new Array("日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日");
//Ensure correct for language. English is "January 1, 2004"
//var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
var year = d.getFullYear();
if (year < 1900) year += 1900;
var TODAY = year+"年"+(d.getMonth()+1)+"月"+d.getDate()+"日 "+dayName[d.getDay()];
//---------------   END LOCALIZEABLE   ---------------

<!--
// 変数定義
var click_flg = false;

function isChecked(frm, name){
	var elems = frm.elements;
	var n = elems.length;
	var cflg = false;
	for (var i = 0; i < n; ++i) {
		var e = elems[i];
		if(e.name == name && e.checked){
			cflg = true;
			break;
		}
	}
	return cflg;
}

function open_w(url) {
	return window.open(url, '_blank');
}

function open_w2(url, t, s) {
	return window.open(url, t, s);
}


//処理実行中メッセージ
function processRunningMsg(){
	if(window.opener == undefined){
		var con = confirm("【処理を中断しますか？】\n\n現在処理を行っております。\n処理を中断する場合は「ＯＫ」\n処理を継続する場合は「キャンセル」をクリックしてください。");
		if (con) return true;
	} else {
  	var con = confirm("【処理を中断しますか？】\n\n現在処理を行っております。\n処理を中断して画面を閉じる場合は「ＯＫ」\n処理を継続する場合は「キャンセル」をクリックしてください。");
		if (con) { 
			self.close();
		} 	
	}

	return false;
}


function click_chk() {

	if (click_flg==false){
		click_flg=true;
		return true;
	}

	return processRunningMsg();
}

// チェックボックス
function checked_all(frm, elm, ename) {
	var elems = frm.elements;
	var status = elm.checked;
	var n = elems.length;
	for (var i = 0; i < n; ++i) {
		var e = elems[i];
		if(e.name == ename) {
			e.checked = status;
		}
	}
}

// 日付を確認
function sub_checkDate(frm) {
	if (click_flg==true){
		processRunningMsg();
		return;
	}
	var a = frm;

  a.date.value = createDate(a.date.value);  

	var date0 = a.date.value;

	var d0 = isDate(date0);	// From日付をチェック
	if (d0 != 1) {
		return;
	}
	click_flg=true;
	frm.submit();
}

// 日付を確認
function sub_checkDates(frm) {
	if (click_flg==true){
		processRunningMsg();
		return;
	}
	var a = frm;

    a.from_date.value = createDate(a.from_date.value);  
    a.to_date.value = createDate(a.to_date.value);

	var date0 = a.from_date.value;
	var date1 = a.to_date.value;

	var d0 = isDate(date0);	// From日付をチェック
	if (d0 != 1) {
		return;
	}
	var d1 = isDate(date1);	// To日付をチェック
	if (d1 != 1) {
		return;			// [E] return false
	}
	var order = checkOrder(date0,date1);	// 日付の順番OK？
	if (order != 1) {
		return;			// [E] return false
	}
	click_flg=true;
	frm.submit();
	//location.href = frm.action + '?from_date=' + date0 + '&to_date=' + date1 + '&' + ctv;
}

function check_ElementDates(felm, telm) {

  felm.value = createDate(felm.value);  
  telm.value = createDate(telm.value);

	var date0 = felm.value;
	var date1 = telm.value;

	if(date0 != ""){
		var d0 = isDate(date0);	// From日付をチェック
		if (d0 != 1) {
			return false;
		}
	}

	if(date1 != ""){
		var d1 = isDate(date1);	// To日付をチェック
		if (d1 != 1) {
			return false;			// [E] return false
		}
	}
	
	if(date0 != "" && date1 != ""){
		var order = checkOrder2(date0,date1);	// 日付の順番OK？
		if (order != 1) {
			return false;			// [E] return false
		}
	}	
	return true;
}


function isDate(date) {
	// [入力なし] true
	if (date == '') {
		return true;
	}
	//文字列桁数チェック
	if (date.length != 10) {
        alert("'YYYY/MM/DD' または 'YYYY-MM-DD' でご入力ください");
        return 0;					// [E] return 0
    }

    var yy = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 29);
	date.match(/(\d+)(\D)(\d+)(\D)(\d+)/);
    var wYear  = RegExp.$1;			// 年
    var hifuna  = RegExp.$2;		// ハイフン
    var wMonth = wMChk = RegExp.$3;	// 月
    var hifunb  = RegExp.$4;		// ハイフン
    var wDay   = RegExp.$5;			// 日

	/*
    var wYear, wMonth,wDay,wMChk,hifunb,hifuna;
    wYear  = date.substring(0,4);
    wMonth  = date.substring(5,7);
    wDay   = date.substring(8,10);
    wMChk = wMonth;
    */

    hifuna  = date.substring(4,5);
    hifunb  = date.substring(7,8);

    //半角数字チェック
    if(!(CheckNum(wYear + wMonth + wDay))){
        alert("年月日は半角数字でご入力ください");
        return 0;					// [E] return 0
    }

    //ハイフンチェック
    if (!(hifuna == "-" || hifuna == "/")) {
        alert("区切り文字は '-' または '/' でご入力ください");
        return 0;					// [E] return 0
    }
    if (!(hifunb == "-" || hifunb == "/")) {
        alert("区切り文字は '-' または '/' でご入力ください");
        return 0;					// [E] return 0
    }
    if (!(hifuna == hifunb)) {
        alert("区切り文字は '-' または '/' で統一してください");
        return 0;					// [E] return 0
    }
    // 年の範囲をチェック
    if (!(wYear >= "2000" && wYear <= "2100")) {
        alert("年の指定が正しくありません");
        return 0;
    }
    // 月の範囲をチェック
    if (!(wMonth >= 1 && wMonth <= 12)) {
        alert("月の指定が正しくありません");
        return 0;					// [E] return 0
    }
    // 閏年を確認
    if (!(wYear % 4) && wMonth == 2) {
        wMChk = 12;     // 閏年テーブル
        if (!(wYear % 100)) {
            if (wYear % 400) {
                wMChk = 1;
            }
        }
    }
	else {
        wMChk--;
    }
    // 日の範囲検証
    if (!(1 <= wDay && yy[wMChk] >= wDay)) {
        alert("日付の指定が間違ってます");
        return 0;					// [E] return 0
    }
    // [OK] return 1

    return 1;
}

// 日付を整形
function createDate(date) {
	var tmpYY;
	var tmpMM;
	var tmpDD;
	var Delimiter;
	var tmpDate = date;
	// 年,デリミタの検索
	if (tmpDate.indexOf("-",0)!=-1){
		tmpYY=tmpDate.substring(0,tmpDate.indexOf("-",0))
		tmpDate = tmpDate.substring(tmpDate.indexOf("-",0)+1,tmpDate.length)
		Delimiter="-"
	}else{
		if (tmpDate.indexOf("/",0)!=-1){
			tmpYY=tmpDate.substring(0,tmpDate.indexOf("/",0))
			tmpDate = tmpDate.substring(tmpDate.indexOf("/",0)+1,tmpDate.length)
			Delimiter="/"
		}else{
			return date;
		}
	}
	// 月,日の検索
	if (tmpDate.indexOf(Delimiter,0)!=-1){
		tmpMM=tmpDate.substring(0,tmpDate.indexOf(Delimiter,0))
		tmpDD = tmpDate.substring(tmpDate.indexOf(Delimiter,0)+1,tmpDate.length)
	}else{
		return date;
	}
	// 月の前zero補てん
	if(tmpMM.length==1){
		tmpMM="0"+tmpMM;
	}
	// 日の前zero補てん
	if(tmpDD.length==1){
		tmpDD="0"+tmpDD;
	}
	if(!(tmpYY.length==4 && tmpMM.length==2 && tmpDD.length==2)){
		return date;
	}
	tmpDate=tmpYY + Delimiter + tmpMM + Delimiter + tmpDD
	return tmpDate;
}


////////////// 

function CheckDown(frm,el) {
	if (click_flg==true){
		processRunningMsg();
		return false;
	}
	if (frm.fileoutput.value > 0 ){
		OpenDataOutView ( frm );
	} else {
		alert("出力形式を選択してください");
	}
}

function ExportClick(frm,value) {
	if (click_flg==true){
		processRunningMsg();
		return false;
	}
	frm.fileoutput.value = value;
	OpenDataOutView ( frm );
}

//「戻る」ボタン対応　強制的にフラグを無効に
function initClickFlag(){
	if (click_flg==false){
		return true;
	}
}

// 半角数字を確認
function CheckNum(str) {
	var code;
	for (var i = 0; i < str.length; i++) {
		code = str.charCodeAt(i);
		if (code < 48 || code > 57) {
			if (!((i==0)&&(code==45))){
				return false;
			}
		}
	}
	return true;
}

// 空白チェック
function checkRequire(obj, name, focus) {
	if(focus == undefined) focus = true;
	if(trim(obj.value) == '' || trim(obj.value).match(/^[　\s]+$/) ) {
		alert(name + ' が入力されていません。');
		if(focus) obj.focus();
		return false;
	}
	return true;
}

function checkOrder(d0,d1) {
/*
	if (d0 != "" ||d1 != ""){
		return 1;
	}
	if (d0>d1){
		alert("集計期間が不正です。");
		return 0;
	}
	return 1;
	*/
	d0.match(/(\d+)\D(\d+)\D(\d+)/);
    var Year1  = RegExp.$1;			// 年
    var Month1 = RegExp.$2;     	// 月
    var Day1   = RegExp.$3;			// 日
    var dd0 = Year1 + '-' + Month1 + '-' + Day1;

	d1.match(/(\d+)\D(\d+)\D(\d+)/);
    var Year2  = RegExp.$1;			// 年
    var Month2 = RegExp.$2;     	// 月
    var Day2   = RegExp.$3;			// 日
    var dd1 = Year2 + '-' + Month2 + '-' + Day2;

	var cmp = dd0 > dd1;
	if (cmp == true) {
		alert("集計期間が不正です。");
		return 0;
	}
	return 1;
	
}

function checkOrder2(d0,d1) {
/*
	if (d0 != "" ||d1 != ""){
		return 1;
	}
	if (d0>d1){
		alert("期間が不正です。");
		return 0;
	}
	return 1;
	*/
	d0.match(/(\d+)\D(\d+)\D(\d+)/);
    var Year1  = RegExp.$1;			// 年
    var Month1 = RegExp.$2;     	// 月
    var Day1   = RegExp.$3;			// 日
    var dd0 = Year1 + '-' + Month1 + '-' + Day1;

	d1.match(/(\d+)\D(\d+)\D(\d+)/);
    var Year2  = RegExp.$1;			// 年
    var Month2 = RegExp.$2;     	// 月
    var Day2   = RegExp.$3;			// 日
    var dd1 = Year2 + '-' + Month2 + '-' + Day2;

	var cmp = dd0 > dd1;
	if (cmp == true) {
		alert("期間が不正です。");
		return 0;
	}
	return 1;
	
}

function checkOrder3(d0,d1, name) {

	d0.match(/(\d+)\D(\d+)\D(\d+)/);
    var Year1  = RegExp.$1;			// 年
    var Month1 = RegExp.$2;     	// 月
    var Day1   = RegExp.$3;			// 日
    var dd0 = Year1 + '-' + Month1 + '-' + Day1;

	d1.match(/(\d+)\D(\d+)\D(\d+)/);
    var Year2  = RegExp.$1;			// 年
    var Month2 = RegExp.$2;     	// 月
    var Day2   = RegExp.$3;			// 日
    var dd1 = Year2 + '-' + Month2 + '-' + Day2;

	var cmp = dd0 > dd1;
	if (cmp == true) {
		alert(name + 'が不正です');
		return 0;
	}
	return 1;
	
}

function checkOrder4(d0,d0h,d0m,d0s,d1,d1h,d1m,d1s,name) {

	d0.match(/(\d+)\D(\d+)\D(\d+)/);
    var Year1  = RegExp.$1;			// 年
    var Month1 = RegExp.$2;     	// 月
    var Day1   = RegExp.$3;			// 日
    var dd0 = Year1 + '-' + Month1 + '-' + Day1;

	d1.match(/(\d+)\D(\d+)\D(\d+)/);
    var Year2  = RegExp.$1;			// 年
    var Month2 = RegExp.$2;     	// 月
    var Day2   = RegExp.$3;			// 日
    var dd1 = Year2 + '-' + Month2 + '-' + Day2;

	var dd0hms = d0h + ':' + d0m + ':' + d0s;
	var dd1hms = d1h + ':' + d1m + ':' + d1s;

	var cmp = dd0 > dd1;
	if (cmp == true) {
		alert(name + 'が不正です');
		return 0;
	}
	if ( dd0 == dd1 ) {
		if ( dd0hms > dd1hms ) {
			alert(name + 'が不正です');
			return 0;
		}
	}
	return 1;
	
}

function checkMaxDate(date, name) {
	year = date.substring(0,4);
	if (year >= "2037") {
		alert(name + 'は2037年以前を入力してください');
		return 0;
	}
	return 1;

}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function preloadImage(src) {
	if (document.images) {
		var img = new Image();
		img.src = src;
	}
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function OpenExpWindow(url,wid) {
var w = window.open(url, "exp", "width=" + wid + ",height=540,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,location=no,directories=no,status=0");
return false;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

  function Trim(el){
  	var str = el.value;
    str = str.replace(/^[ 　]+/,"");
    str = str.replace(/[ 　]+$/,"");
    el.value = str;
  }
  

function trim(str) {
	while(str.charAt(0)==" "){str=str.substring(1,str.length)}
	while(str.charAt(str.length-1)==" "){str=str.substring(0,str.length-1)}
	return str;
}

function OpenDataOutView ( frm ){

		if ( frm.fileoutput.value == 1 ){
			frm.dtype.value = "Csv";
		} else if ( frm.fileoutput.value == 2 ){
			frm.dtype.value = "Pdf";
		} else if ( frm.fileoutput.value == 3 ){
	 	  window.open('view/print/dataout.htm','dataout','menubar=yes,toolbar=yes,scrollbars=yes,resizable=yes,width=650,height=700');
	 	  return;
		} else if ( frm.fileoutput.value == 4 ){
			frm.dtype.value = "Excel";
		} else {
			frm.dtype.value = ''
		}

		frm.m.value = 'fileout';
		frm.submit();
		frm.target.value = '';
		frm.dtype.value  = '';

}


function openClose(objId, imgObjId, srcOpen, srcClose)
{
	var obj = getObjById(objId);
	
	var status = (obj.style.display == "none");
	status = !status;
	
	obj.style.display = (status ? "none" : "");
	
	if(imgObjId != undefined && imgObjId != '') {
		var imgObj = getObjById(imgObjId);
		imgObj.src = "view/images/" + (status ? srcClose : srcOpen);
	}
}


function openObj(objId)
{
	var obj = getObjById(objId);
	
	obj.style.display = "";
	
}


function openCloseAll(objName)
{
	var elements = document.getElementsByName(objName);
	for(var i = 0; i < elements.length; i++) {
		var obj = elements[i];
		var status = (obj.style.display == "none");
		status = !status;
		
		obj.style.display = (status ? "none" : "");
	}
}

function getObjById(objId)
{
	return document[document.all ? "all": "getElementById"](objId);
}


function openCloseMenu(menuId, arrowId)
{
	openClose(menuId, arrowId, 'node_open.gif', 'node_close.gif');
}

function openCloseSidemenu()
{
	var obj = getObjById('sidemenu');
	var status = (obj.style.display == "none");
	if(status == '' && confirm('メニューを非表示にします。\nよろしいですか？') == false) return false;
	
	openClose('sidemenu', 'side_bar_arrow', 'arrow_left.gif', 'arrow_right.gif');
	
	var frm = document.mainform;
	if(frm != undefined && frm.elements['sidemenu_display'] != undefined) {
		frm.elements['sidemenu_display'].value = obj.style.display;
	}
	
	frm = document.inputform;
	if(frm != undefined && frm.elements['sidemenu_display'] != undefined) {
		frm.elements['sidemenu_display'].value = obj.style.display;
	}
}

function openCloseTopmenu()
{
	var obj = getObjById('topmenu');
	var status = (obj.style.display == "none");
	if(status == '' && confirm('上部メニューを非表示にします。\nよろしいですか？') == false) return false;
	
	openClose('topmenu');
	
	var frm = document.mainform;
	if(frm != undefined && frm.elements['topmenu_display'] != undefined) {
		frm.elements['topmenu_display'].value = obj.style.display;
	}
	
	frm = document.inputform;
	if(frm != undefined && frm.elements['topmenu_display'] != undefined) {
		frm.elements['topmenu_display'].value = obj.style.display;
	}
}

function openCloseSearchDetail()
{
	openClose('search_detail');
	var obj = getObjById('search_detail');
	
	var frm = document.mainform;
	if(frm != undefined && frm.elements['search_detail_display'] != undefined) {
		frm.elements['search_detail_display'].value = (obj.style.display == 'none' ? 0 : 1);
	}
}

function openCloseKeywordRanking()
{
	openClose('keywordRanking');
	var obj = getObjById('keywordRanking');
	
	var frm = document.mainform;
	if(frm != undefined && frm.elements['keywordRanking_display'] != undefined) {
		frm.elements['keywordRanking_display'].value = (obj.style.display == 'none' ? 0 : 1);
	}
}


// 一括チェック
function check_all(isCheck, target_name){
	var elements = document.getElementsByName(target_name);
	for(var i = 0; i < elements.length; i++) {
		elements[i].checked = isCheck;
	}
}

function getWindowWidth(){
	if (window.innerWidth){
		return window.innerWidth;}	
	else if (document.documentElement && document.documentElement.clientWidth != 0){
		return document.documentElement.clientWidth;	}
	else if (document.body){return document.body.clientWidth;}		
		return 0;
}

function getWindowHeight(){
	if (window.innerHeight){
		return window.innerHeight;}	
	else if (document.documentElement && document.documentElement.clientHeight != 0){
		return document.documentElement.clientHeight;	}
	else if (document.body){return document.body.clientHeight;}		
		return 0;
}

// ラジオボタンのチェックされた値を取得
function getRadioValue(obj_name){
	var elements = document.getElementsByName(obj_name);
	for(var i = 0; i < elements.length; i++) {
		if(elements[i].checked) {
			return elements[i].value;
		}
	}
	return null;
}

// ラジオボタンをチェックする
function setRadioValue(obj_name, value){
	var elements = document.getElementsByName(obj_name);
	for(var i = 0; i < elements.length; i++) {
		if(elements[i].value == value) {
			elements[i].checked = true;
			return;
		}
	}
}

// class="class1" の値を書き換える
function setClassName(obj_id, class_name) {
	var obj = getObjById(obj_id);
	if(obj != undefined) {
		obj.setAttribute((document.all ? 'className' : 'class'), class_name);
	}
}

// 特定の文字列で始まる
function startsWith(text, val) {
	if(text == '' || val == '') return false;
	if(text.length < val.length) return false;
	var left = text.substring(0, val.length);
	return (left == val);
}

// 特定の文字列で終わる
function endsWith(text, val) {
	if(text == '' || val == '') return false;
	if(text.length < val.length) return false;
	var right = text.substring(text.length - val.length, text.length);
	return (right == val);
}

// htmlの書き換え
function setInnerHtml(obj_id, src) {
	var obj = getObjById(obj_id);
	
	var updater = function() {
		obj.innerHTML = src;
	}
	setTimeout(updater, 0);
}

// パスワード生成
function makePassword(length) {
	var s = "23456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";
	var p = "";
	for(var i = 0; i < length; i++) {
		p += s.charAt(Math.floor(s.length * Math.random()));
	}
	return p;
}

// 文字列を数値に変換
function toNumber(text) {
	var sum = 0;
	for(var i = 0; i < text.length; i++) {
		var c = text.charAt(i);
		if(c < '0' || '9' < c) continue;
		c -= 0;	// 数値に型変換
		sum *= 10;
		sum += c;
	}
	return sum;
}

// テキストエリアでタブ入力
function catchTab(event, obj) {
	var eventObj = null;
	if(event.srcElement) eventObj = event.srcElement;
	else if(event.target) eventObj = event.target;
	
	if (event.keyCode != 9 || eventObj != obj) return true;
	
	if(document.all) {
		// IE: keydown
		obj.selection = document.selection.createRange();
		obj.selection.text = "\t";
		event.returnValue = false;
		
	} else {
		// Gecko : keypress
		text = obj.value;
		var start = obj.selectionStart;
		var end = obj.selectionEnd;
		obj.value = text.slice(0, start) + "\t" + text.slice(end);
		obj.focus();
		obj.setSelectionRange(start + 1, start + 1);
		event.stopPropagation();//Firefox
		
	}
	
	return false;
}
// 終了日なし
function set_no_end_date() {
	document.inputform.end_date.value = '';
}

// 一括更新
function sub_update_all(url){
	var frm = document.mainform;

	//var act = frm.action_org.value;
	var ids = get_sel_ids(frm, 'sel');

	if( ids == '' ) {
		alert("一括更新する対象を選択してください。");
		return false;
	}
	
	//url += '?';
	//url += 'ids=' + ids;


	popUp(url, 'popup');
	
	/*var pars = 'a=' + act;
	pars += '&m=' + 'update_all_input';
	pars += '&media_id=' + frm.search_media.value;
	pars += '&ids=' + ids;
	sub_popup('update_all', pars);*/
}


function popUp(url,id){
	open_w2(url, id, 'width=800,height=720,resizable=yes,scrollbars=yes,status=yes');
}

// 更新
function sub_refresh(){
	setTimeout(sub_list, 0);
}

// サブミット
function sub_do(frm, mod) {
	alert(frm);
	sub_all(frm, frm.action_org.value, mod);
}
function sub_all(frm, act, mod) {
	if(!click_chk()) return false;
	
	//showLoading();
	alert(mod);
	frm.elements[actionName].value = act;
	frm.elements[moduleName].value = mod;
	frm.submit();
}

// ダウンロード
function sub_download(frm, mod) {
	if(mod == undefined) mod = 'download';
	frm.elements[moduleName].value = mod;
	frm.submit();
}

// キャッシュの指定を外すためのパラメータ
function param_nocache() {
	var tv = (new Date).getTime();
	return '&tv_for_nocache=' + tv;
}

// アンカータグの代わり
function sub_redirect(act, args) {
	var pars = 'a=' + act;
	if(args != undefined && args != '') {
		if(args.charAt(0) != '&') args = '&' + args;
		pars += args;
	}
	var frm = document.mainform;

	if(frm != undefined && frm.topmenu_display != undefined) pars += '&topmenu_display=' + frm.topmenu_display.value;
	pars += param_nocache();
	
	showLoading();
	
	var url = 'index.php?' + pars;
	location.href = url;
}

// ポップアップ表示
function sub_popup(window_id, pars) {
	var url = 'index.php?' + pars + '&popup=1' + param_nocache();
	if(document.mainform != undefined) url += '&account_id_org=' + document.mainform.account_id_org.value;
	return open_w2(url, window_id, 'width=800,height=720,resizable=yes,scrollbars=yes,status=yes');
}


// 削除
function sub_delete(msg){
	var frm = document.mainform;
	if(sub_delete_proc(frm, 'del') == false) return false;
	sub_do(frm, 'delete');

}

// 削除
function sub_delete2(){
	var frm = document.mainform;
	if(sub_delete_proc(frm, 'del') == false) return false;
	frm.action.value="DEL";
	frm.submit();

}

function sub_delete_proc(frm, obj_name, msg){
	var ids = get_sel_ids(frm, obj_name);
	if( ids == '' ) {
		alert("削除する対象を選択してください。");
		return false;
	}
	if(msg == undefined || msg == '') msg = "削除します。\nよろしいですか？";
	if( !window.confirm(msg) ) return false;
	frm.del_ids.value = ids;
	return true;
}

function sub_admin_login(){
	var frm = document.loginform;
	frm.account_id.value = 'empty';
	frm.login_id.value = 'empty';
	frm.password.value = 'empty';
	frm.login_type.value = 'admin';
	if (!sub_all(frm, 'login/Login', '')) return false;

}


// 確認
function confirm_regist(){
	msg = "登録します。\nよろしいですか？";
	return window.confirm(msg);
}
function confirm_delete(){
	msg = "削除します。\nよろしいですか？";
	return window.confirm(msg);
}

// 絞込
function sub_filter(){
	var frm = document.mainform;
	var ids = get_sel_ids(frm, 'sel');
	if( ids == '' ) {
		alert("絞り込む対象を選択してください。");
		return false;
	}
	frm.sel_ids.value = ids;	
	sub_do(frm, 'list');

}
function sub_filter_reset(){
	var frm = document.mainform;
	frm.sel_ids.value = '';	
	sub_do(frm, 'list');

}

function get_sel_ids(frm, obj_name) {
	var ids = '';
	var elements = document.getElementsByName(obj_name);
	for(var i = 0; i < elements.length; i++) {
		if(elements[i].form != frm) continue;
		if(elements[i].checked) {
			if(ids != '') ids += ',';
			ids += elements[i].value;
		}
	}
	return ids;
}


// 一覧
function sub_list(){
	var frm = document.mainform;
	if(frm.from_date != undefined && !isDate(frm.from_date.value)) return false;
	if(frm.to_date != undefined && !isDate(frm.to_date.value)) return false;
	if(frm.from_date != undefined && frm.to_date != undefined && !checkOrder3(frm.from_date.value, frm.to_date.value, '期間')) return false;
	sub_do(frm, 'list');
	return false;
}

// ページ行切替
function sub_change_lines(lines){
	var frm = document.mainform;
	sub_change_lines_proc(frm, lines);
	frm.elements['control'].value = 'page';
	sub_list();
}
function sub_change_lines_proc(frm, lines){
	frm.elements['lines_per_page'].value = lines;
	frm.elements['page_no'].value = 1;
}

// ページ切替
function sub_change_page(page_no){
	var frm = document.mainform;
	frm.elements['page_no'].value = page_no;
	frm.elements['control'].value = 'page';
	sub_list();
}
function sub_add_page(offset, page_no, page_max){
	var frm = document.mainform;
	sub_add_page_proc(frm, offset, page_no, page_max);
	frm.elements['control'].value = 'page';
	sub_list();
}
function sub_add_page_proc(frm, offset, page_no, page_max){
	var new_no = page_no + offset;
	if(new_no < 1) new_no = 1;
	if(new_no > page_max) new_no = page_max;
	frm.elements['page_no'].value = new_no;
}

// 並べ替え
function sub_sort(sort_column, sort_order){
	var frm = document.mainform;
	sub_sort_proc(frm, sort_column, sort_order);
	frm.elements['control'].value = 'sort';
	sub_list();
}
function sub_sort_proc(frm, sort_column, sort_order){
	var org_column = frm.elements['sort_column'].value;
	var org_order = frm.elements['sort_order'].value;
	if(org_column == sort_column) {
		sort_order = (org_order == 'desc' ? 'asc' : 'desc');
	}
	frm.elements['sort_column'].value = sort_column;
	frm.elements['sort_order'].value = (!sort_order ? 'asc' : sort_order);
}

// 削除チェック
function change_check(each_name, all_id){
	var frm = document.mainform;
	change_check_proc(frm, each_name, all_id);
}
function change_check_proc(frm, each_name, all_id){
	var elements = document.getElementsByName(each_name);
	var all_checked = true;
	for(var i = 0; i < elements.length; i++) {
		if(elements[i].form != frm) continue;
		if(elements[i].checked == false) {
			all_checked = false;
			break;
		}
	}
	var objAll = getObjById(all_id);
	objAll.checked = all_checked;
}

//-->